
<!DOCTYPE html>
<html lang="zh" style="background-color: #fff;" >
<head>
	<meta charset="utf-8" />
	<title>大数据开放平台</title>   
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"  />
	<link href="${mvcPath}/dacp-lib/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" media="screen"/>
  <link rel="stylesheet" href="${mvcPath}/dacp-view/aijs/css/font-awesome.min.css" type="text/css" />
  <link href="${mvcPath}/dacp-lib/fuelux/fuelux.min.css" type="text/css" rel="stylesheet" media="screen"/>
  <link href="${mvcPath}/dacp-view/aijs/css/ai.css" type="text/css" rel="stylesheet" />
  <link href="${mvcPath}/dacp-res/me/css/ai.meta.css" type="text/css" rel="stylesheet"/>
  <script type="text/javascript" src="${mvcPath}/dacp-lib/jquery/jquery-1.10.2.min.js"></script>
  <link rel="stylesheet" href="${mvcPath}/dacp-res/me/css/jquery-ui.css">
  <script src="${mvcPath}/dacp-res/me/js/jquery-ui.js"></script>
  
<script type="text/javascript" src="${mvcPath}/dacp-lib/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${mvcPath}/dacp-lib/underscore/underscore-min.js"></script>
<script src="${mvcPath}/dacp-lib/jquery-plugins/jquery-contextMenu.js"></script>
<script src="${mvcPath}/dacp-lib/jquery-plugins/jquery-artDialog.js"></script>
<script src="${mvcPath}/dacp-lib/fuelux/fuelux.min.js"></script>
<script src="${mvcPath}/dacp-lib/cryptojs/aes.js" type="text/javascript"></script>
<script src="${mvcPath}/crypto/crypto-context.js" type="text/javascript"></script>
<script src="${mvcPath}/dacp-view/aijs/js/ai.core.js"></script>
 
<script src="${mvcPath}/dacp-view/aijs/js/ai.field.js"></script>
<script src="${mvcPath}/dacp-view/aijs/js/ai.jsonstore.js"></script>
 
<script src="${mvcPath}/dacp-view/aijs/js/ai.grid.ux.js"></script>

<script src="${mvcPath}/dacp-view/aijs/js/ai.treeview.js"></script>
<script src="${mvcPath}/dacp-lib/ztree/jquery.ztree.all-3.5.min.js"></script> 
<script src="${mvcPath}/dacp-res/catalog/common/js/ai.meta.widget.js"></script>

<script src="${mvcPath}/dacp-res/catalog/common/js/ai.treeindex.js"></script>
 <style>
  body{
    -moz-user-select: none;
  }
  .repeater{
    border:0px;
  }
  .tree{
    border:0px;
  }
    .bg-light.dk, .bg-light .dk {
background-color: #e0eaec;
}
.pull-out {
margin: -10px -15px;
}
.repeater-thumbnail{
  border:0px;
}
.repeater-thumbnail .panel{
  margin-bottom:0px;
}
.padder-v {
padding-top: 15px;
padding-bottom: 15px;
}
.m-b-xs {
margin-bottom: 5px;
}
.block {
display: block;
}
/*
.dacptiles,.thumbnail,repeater-thumbnail  {
color: #225;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-o-transition: all 0.2s;
-ms-transition: all 0.2s;
transition: all 0.2s;
width: 80px;
overflow: hidden;
height: 80px;
text-decoration: none;
float: left;
margin-right: 10px;
margin-bottom: 0px;
border:0px;
}*/
.dacptiles .icon{
margin-top: 5px;
margin-bottom: 10px;
font-size: 32px;
}
.dacptiles .title{
display: block;
text-align: center;
word-wrap: break-word;
font-size:12px;
}
.isotope,
.isotope .isotope-item {
  -webkit-transition-duration: 0.8s;
     -moz-transition-duration: 0.8s;
       -o-transition-duration: 0.8s;
          transition-duration: 0.8s;
}

.isotope {
  -webkit-transition-property: height, width;
     -moz-transition-property: height, width;
       -o-transition-property: height, width;
          transition-property: height, width;
}
.repeater-thumbnail{
	text-align:left;
}
 .dacptiles{
  width: 270px;
  height: 180px;
  z-index: 100;
  overflow:hidden;
  text-align: center;
   /* border:1px #f2f5f5 solid*/
}
.dacptiles.large{
	 
  width: 470px;
  //height: 250px;
  z-index: 100;
  overflow:hidden;
}
.dacptiles .detail{
	border-top:#f2f5f5 solid
}
small{
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.fieldinfo small{
    float: left;
}

.form-horizontal .form-group {
    margin-left: 0px;
    margin-right: 0px;
}
.tooltip{z-index: 9999;width: 180px;position:fixed;margin-left:15px!important;}
.frame-main .frame-left {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 199px;
  border-right: 1px solid #ddd;
  background: #f3f3f3;
  background-attachment: fixed;
  overflow: auto;
  z-index: 1;
}
.ui-progressbar {
    position: relative;
  }
  .progress-label {
    position: absolute;
    left: 50%;
    top: 4px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #fff;
  }
.repeater-title .total{color:red;margin-left:5px;}

#frame-right-main .repeater-header .toolbar .input-append {
    width: auto;
}
  </style>

<script>
$(document).ready(function() {
var rootCode=paramMap.modelcode;
var loadMethod = paramMap.loadmethod;
var targetCode = paramMap.targetcode||'';
_METAPRJ = paramMap.METAPRJ?'_'+paramMap.METAPRJ:'';
var zTree=null;
var loadtype=paramMap.loadtype||'loadmenu';//加载模式：从菜单加载,paramMap.modelcode有值,从paas团队加载,paramMap.teamcode,按数据库加载,param.database有值

AI.Explore= Event.$extend({
  _listeners:{},
  itemStore:null,
   __init__ : function(options) {
      this.options= $.extend(true, this.default, options);
      this._listeners={};
      this.listView = new AI.MetaList({ });
      //this.buildExporeContextMenu();
      //this.init( this.options);
   },
  init:function(treeNode){
     this.gotoPath(treeNode);
  },
  getTreeWhere:function(treeNode){
    var result={where:'',fieldInfoArray:[]};
    var where="";
 
    var tmpArray=[];
    var curTreeNode=treeNode;
    while(treeNode){
          if(treeNode.fieldname){
        var fieldname =treeNode.fieldname.toLowerCase(); 
        if(tmpArray.indexOf(fieldname)<0){
           if(where) where+=' and '+fieldname+"='"+treeNode.id+"' "
           else where=fieldname+"='"+treeNode.id+"' ";
           result.fieldInfoArray.push({fieldname:fieldname,val:treeNode.id});
           tmpArray.push(fieldname);
        }
      }
      treeNode=treeNode.getParentNode();
    };
    ///如果树有filter优先
   
    if(curTreeNode.filter){
    	console.log(curTreeNode);
    	where= curTreeNode.filter;
    	for(var key in curTreeNode){
    		if((typeof curTreeNode[key])=="string"){
    			where=where.replace('{'+key+'}',curTreeNode[key]);
    		}
    	}
    	where=where.replace("{teamcode}",'T0001');
    };
   
    result.where = where;
    return result;
  },
  create:function(options){
  	   ai.loadRemotJsCss("/{contextPath}/"+options.widget);
  	   ai.loadRemotJsCss("/{contextPath}/html/dataindex/jquery.isotope.js"); 
  	   // var listView = new window[options.widgetName];
  	   var listView = new AI.MetaList.DataSendApply({show:true,objtype:'TAB', containerId:'frame-right-main'});
  },
  gotoPath:function(treeNode){
    if(!treeNode) return;
    if(treeNode.url){
      $("#frame-right-main").hide();
      
      var _url="/"+contextPath+"/"+treeNode.url;
      _url=_url.replace('{contextPath}',contextPath);
      $("#frame-right-iframe").attr("src",_url).show();
      return ;
    }
    var objtype=treeNode.objtype;
    // console.log(treeNode);
    if(treeNode.children && treeNode.children.length>0){
      objtype="folder";
       this.itemStore = new AI.JsonStore({
                data:[],
                key:"XMLID"
            });
            for(var i=0;i<treeNode.children.length;i++){
              var node =treeNode.children[i];
              var itemRec=this.itemStore.getNewRecord();
              itemRec.set('OBJTYPE','folder');
              itemRec.set('NODETYPE','');
              itemRec.set('OBJICON','glyphicon-folder-open');
              itemRec.set('XMLID',node.id);
              itemRec.set('OBJCODE',node.id);
              itemRec.set('OBJNAME',node.id);
              itemRec.set('OBJCNNAME',node.name);
              this.itemStore.add(itemRec);
            };
    }
    else{
      this.itemStore=null;
      var metaInfo = this.listView.getMetaInfo(objtype);
      var metastoretype='frommetaboj';
      var toolbarconfig = [];
      var fieldInfoArray = [];
      var where="" 
      var result = this.getTreeWhere(treeNode);
      fieldInfoArray = result.fieldInfoArray;
      //if(objtype) where +=" and objtype='"+objtype+"'";
      //if(treeNode.fieldname) where += " and "+treeNode.fieldname+"='"+treeNode.id+"'";
      if(result && result.where){
        where += " and "+result.where;
      }
      if(MainFram.treeIndex.teamcode){
        where += " and team_code = '"+MainFram.treeIndex.teamcode+"'";
      }
      // var strsql="select * from metaobj where 1=1 "+where;
      // this.itemStore = new AI.JsonStore({ sql: strsql  , pageSize:50, key:"XMLID" });

      
      if(objtype == 'TOPIC'){
        // strsql += " order by objtype ";
        // this.itemStore.select(strsql);
        toolbarconfig = [
          {type:'text',fieldLabel:'对象名称',width:120,name:'name',where:"(upper(OBJNAME) like upper('%{name}%') or upper(OBJCNNAME) like upper('%{name}%'))"},
          {type:'combox',fieldLabel:'状态',width:120,name:'state',storesql:"select rowcode,rowname from metaedimdef where dimcode = 'DIM_STATE'",where:"state = '{state}'"},
          {type:'text',fieldLabel:'负责人',width:120,name:'curdutyer',where:"upper(CURDUTYER) like upper('%{curdutyer}%')"}
        ];
        var createBtnGroup = {type:'buttongroup',dropIndex:'0',fieldLabel:'新建 ...',name:'create',fields:[]};
        var exportBtnGroup = {type:'buttongroup',dropIndex:'0',fieldLabel:'导出 ...',name:'export',fields:[]};
        var dbTreeNode = _.find(result.fieldInfoArray, function(obj){ 
          if(obj.fieldname == 'dbname'){
            return obj;
          }
        });
        var funcIds = [],funcNames = [];
        if(loadtype != "paas") {
          var dbStruct = new AI.JsonStore({ sql: "select func_id,func_name  from metadb_struct WHERE DBNAME = '"+dbTreeNode.val+"' AND rulecode = '"+treeNode.id+"'"  , pageSize:-1 });
          if(dbStruct.getCount()>0){
            funcIds = dbStruct.getAt(0).get('FUNC_ID')?dbStruct.getAt(0).get('FUNC_ID').split(','):funcIds;
            funcNames = dbStruct.getAt(0).get('FUNC_NAME')?dbStruct.getAt(0).get('FUNC_NAME').split(','):funcIds;
          }
        } else {
          var teamcode = MainFram.treeIndex.teamcode;
          var teamStruct = new AI.JsonStore({ sql: "select RULETEXT  from META_TEAM_PERMISSION WHERE DBNAME = '"+dbTreeNode.val+"' AND topicname = '"+treeNode.id+"' AND team_code = '" + teamcode + "'"  , pageSize:-1 });
          if(teamStruct.getCount()>0){
            funcIds = teamStruct.getAt(0).get('RULETEXT')?teamStruct.getAt(0).get('RULETEXT').split(','):funcIds;
            var metastore = new AI.JsonStore({ sql: "select objtype, objname from metaobjmodel", pageSize:-1, key: "OBJTYPE" });
            for(var i in funcIds) {
              var _objtype = funcIds[i];
              var r = metastore.getRecordByKey(_objtype);
              var objname = r.get("OBJNAME");
              funcNames.push(objname);
            }
          }
        }
       
        var objTypeStoreSql = '';
        for(var i=0;i<funcIds.length;i++){
          createBtnGroup.fields.push({actionId:'create'+funcIds[i],name:'create'+funcIds[i],fieldLabel:'新建'+funcNames[i]});
          exportBtnGroup.fields.push({actionId:'export'+funcIds[i],name:'export'+funcIds[i],fieldLabel:'导出'+funcNames[i]});
          objTypeStoreSql +=funcIds[i]+","+funcNames[i]+"|";
        }
        objTypeStoreSql = objTypeStoreSql.substr(0,objTypeStoreSql.length-1);
        if(funcIds.length == 1) {
          objTypeStoreSql = "select '" + funcIds[0] + "', '" + funcNames[0] + "' from dual";
        }
        toolbarconfig.push();
        toolbarconfig.push({type:'selectlist',fieldLabel:'对象类型',width:210,name:'objtype',storesql:objTypeStoreSql,where:"objtype='{objtype}'"});
        toolbarconfig.push({type:'button',fieldLabel:'查询',width:120,name:'query',actionId:'queryMetaObj'});
        toolbarconfig.push(createBtnGroup);
        toolbarconfig.push(exportBtnGroup);
        toolbarconfig.push({type:'button',fieldLabel:'导入',width:120,name:'query',fn:function(){
      	  ai.addTabSheet("importMeta", '导入元数据',  "/"+contextPath+"/ftl/me/meta_imp/meta_upload", true );
        }});
      }
    }
      
    this.listView.showList({containerId:'frame-right-main',store:this.itemStore,objtype:objtype,title:treeNode.name,metastoretype:metastoretype,toolbarconfig:toolbarconfig,fieldInfoArray:fieldInfoArray,teamcode:MainFram.treeIndex.teamcode||'',filter:where
      // ,actions:{'createERGRAPH':{dealtype:'add'}}
      // ,contextMenu:{"rname": {name: '重命名',className: "rname",icon: "pencil",accesskey: "r"}}
      // ,menuItems:{"openTab":{dealtype:"add"},"rname": {name: '重命名',className: "rname",icon: "pencil",accesskey: "r"}}
      // ,dblClick:function(objid,objtype){alert(objid+"-"+objtype);return true;}
    	,treeNode:treeNode
    });
      
    this.listView.removeEvent("dblclick").on("dblclick",function(objid){
      var node = zTree.getNodeByParam("id",objid);
      if(!node) return;
      if(node.getParentNode()&&node.getParentNode().open == false) zTree.expandNode(node.getParentNode());
      if(node) $("#"+node.tId+"_a").click();
    });
  } 
});
MainFram={
  treeIndex:null,
  metaObjList:null,
  _bindFrameSizeEvent: function(){
    var isDraging     = false;
    var mouseFirst    = 0;
    var leftwidthFirst  = 0;
    var min_width   = 0;//最小宽度

    var $left = $('.frame-left');
   
    var $drag = $('.frame-resize');
    var $right= $('.frame-right');
   
       $($drag).off();
       
    $drag.off('mousedown').on('mousedown',function(e){
      if (e.which != 1) return true;
      __dragStart(e);
            //事件 在 window之外操作，继续保持。
      if(this.setCapture) this.setCapture();
      $(document).mousemove(function(e) {__dragMove(e);});
      $(document).one('mouseup',function(e) {       
        __dragEnd(e);
        if(this.releaseCapture) {this.releaseCapture();}
        //stopPP(e);
        return false;
      });
    });
    var __dragStart = function(e){
      isDraging = true;
      mouseFirst = e.pageX;
      leftwidthFirst = $('.frame-left').width();
      $drag.addClass('active');
      $('.resizeMask').css('display','block');
    };
    var __dragMove = function(e){
      if (!isDraging) return true;
      var mouseOffset = e.pageX - mouseFirst;
      var offset = leftwidthFirst+mouseOffset;
      if (offset < min_width) offset = min_width;
      if (offset > $(document).width()-200) offset = $(document).width()-200;

      $left.css('width',offset);
      $drag.css('left',offset-5);
      $right.css('left',offset+1);
    };
    var __dragEnd = function(e){
      if (!isDraging) return false;
      isDraging = false;
      $drag.removeClass('active');
      $('.resizeMask').css('display','none');
       
    };
  },
  writeProfile:function(){}, 
  init:function(){
	  var teamcode="";
	  if(localStorage && localStorage.devindex_teamcode) teamcode = localStorage.devindex_teamcode;
    this.explore=new  AI.Explore({});
    this._bindFrameSizeEvent();
    if(loadtype=='paas'){
      teamcode = teamcode=="undefined"?"":teamcode;
      if(localStorage && localStorage.username != _UserInfo.username) teamcode = "";
      this.treeIndex=new AI.TreeIndex.PaaS ({teamcode:teamcode});
      this.treeIndex.initTree({teamcode:teamcode,rootCode:rootCode,loadMethod:loadMethod});    
    }
    else if(loadtype=='dataindex'){
        this.treeIndex=new AI.TreeIndex.DataIndex({});
        this.treeIndex.initTree({loadMethod:loadMethod,targetCode:targetCode});
    }
    else if(loadtype=='metaindex'){
        this.treeIndex=new AI.TreeIndex.MetaIndex({});
        this.treeIndex.initTree({loadMethod:loadMethod,targetCode:targetCode});
    }
    else if(loadtype=='devindex'){
        this.treeIndex=new AI.TreeIndex.DevIndex({});
        this.treeIndex.initTree({loadMethod:loadMethod,targetCode:targetCode});
    }
    else{
      this.treeIndex=new AI.TreeIndex({teamcode:''});
      this.treeIndex.initTree({rootCode:rootCode,loadMethod:loadMethod,targetCode:targetCode});
    }
     
    if(!targetCode) this.explore.init(this.treeIndex.getRoot());
    zTree = $.fn.zTree.getZTreeObj("folderList");
    /*
    if (!targetCode&&localStorage && localStorage.devindex_treeid && localStorage.username == _UserInfo.username){
	  	  var node = zTree.getNodeByParam("id",localStorage.devindex_treeid);
	        if(!node) return;
	        if(node.getParentNode()) zTree.expandNode(node.getParentNode());
	        if(node) $("#"+node.tId+"_a").click();
	 }
    */
  }
}
 
MainFram.init();
 /*
$(window).bind('beforeunload',function(){
  if (localStorage) {
	  var sNodes = zTree.getSelectedNodes();
	  if(sNodes.length>0){
		  var curNode =sNodes[0];
		  localStorage.devindex_treeid=curNode.id;
	  };
	  localStorage.devindex_teamcode = MainFram.treeIndex.teamcode;
	  localStorage.username = _UserInfo.username;
  }
  return '您输入的内容尚未保存，确定离开此页面吗？';
});
*/
$("#folderList li a span").attr('data-toggle','tooltip').attr('data-placement','right');
$("[data-toggle='tooltip']").tooltip();

});
 
</script>
</head>

<body class="">
     <div class="tipinfo" style="top:0px;position: absolute;left: 0px;right: 0px;bottom:0px;display:none">
        <div class="jumbotron">
            <h2 class='title'>报错了!</h2>
                <p class='content'>This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
                <p><a class="btn btn-primary btn-lg" href="#" role="button">更多信息</a></p>
          </div>
      </div>
    <div class="frame-main" style="top:0px;position: absolute;left: 0px;right: 0px;bottom:0px">
      <div class="frame-left">
        <ul class="nav ">
          <li role="presentation" class="dropdown">
              <a id="treetitle" href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true" style="float:left;">
                 <span class='title'>团队:信息</span> <span class="caret"></span>
              </a>
              <!-- <i id= "catchanger" class="btn glyphicon glyphicon-user" style="float:right;top:5px;display:none"></i> -->
              <ul id="teammenu" class="dropdown-menu">
              </ul>
          </li>
        </ul>
        
        <div id="folderList" class="ztree showIcon" > </div>
     
      </div>
      <div class="frame-resize">
      </div>
      <div class="frame-right" style="height:100%;overflow:hidden">
        <iframe id="frame-right-iframe" src="" style="display:none" width="100%" height="100%" frameborder="0" border="0" marginwidth="0" marginheight="0"> </iframe>
         <div id="frame-right-main"  style="height:100%;"></div>
         <div id="progressbar"></div>
      </div>
   </div>
   
</body>
<script type="text/javascript" src="${mvcPath}/dacp-lib/me/screenWord/screenWordCapturing.js"></script>
</html>